﻿using COMPONENT.Entity;
using COMPONENT.Library.General;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HMS.PresentationWeb.src.app_code
{
    public class BaseSession
    {
        public static clsUsuario SessionUsuario
        {
            get
            {
                return clsExtension.GetSession<clsUsuario>("Usuario") ?? RedirectDistributor<clsUsuario>();
            }
            set
            {
                HttpContext.Current.Session["Usuario"] = value;
            }
        }
        public static clsTarjeta vsTarjeta
        {
            get { return clsExtension.GetSession<clsTarjeta>("vsTarjeta") ?? new clsTarjeta(); }
            set { HttpContext.Current.Session["vsTarjeta"] = value; }
        }
        private static T RedirectDistributor<T>()
        {
            Logout();
            HttpContext.Current.Response.Redirect("default.aspx");
            return default(T);
        }

        private static void Logout()
        {
            HttpContext.Current.Session.Abandon();
            HttpContext.Current.Session.Clear();
        }
    }
}